package interactables;

import game.Game;
import game.InputHandler;

public abstract class Button {
	
	protected InputHandler input;
	protected Game game;
	protected int minX;
	protected int maxX;
	protected int minY;
	protected int maxY;
	protected Tab myTab;
	protected boolean toggle = false;
	protected String name;
	protected int id;
	
	public Button(int minX, int maxX, int minY, int maxY, InputHandler input, Game game, Tab tab, String name, int id) {
		
		this.input = input;
		this.game = game;
		this.minX = minX*Game.SCALE;
		this.maxX = maxX*Game.SCALE;
		this.minY = minY*Game.SCALE;
		this.maxY = maxY*Game.SCALE;
		this.myTab = tab;
		this.name = name;
		this.id = id;
		
		myTab.updateButtonList(this);
	
	}
	
	public void runCheck(double x, double y) {
		
		if (x < maxX && x > minX && y < maxY && y > minY) {
			if (!toggle) {
				toggle = true;
				update();
			}
		}
		
	}
	
	public void unToggle() {
		toggle = false;
	}
	
	public Tab getTab() {
		return this.myTab;
	}
	
	public String toString() {
		return "Name: " + name + ", ID: " + id + ", Toggled: " + toggle;
	}
	
	public abstract void update();
	
	public abstract void render();

}
